﻿using System;
using System.Linq;
using System.Text;
using System.Activities;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;
using System.Collections;
using System.Windows.Markup;
using System.Windows;
using System.Dynamic;

namespace Vision.Core.ActivityComponents.Collections
{
    [Designer(typeof(Vision.Core.ActivityComponents.Collections.DictionaryBuilderDesigner))]
    [ContentProperty("Activities")]
    public class DictionaryBuilder<TKey, TValue> : NativeActivity
    {
        /// <summary>
        /// 
        /// </summary>
        public InOutArgument<Dictionary<TKey, TValue>> Dictionary { get; set; }

        [Browsable(false)]
        public Collection<AddToDictionary<TKey, TValue>> Activities { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public DictionaryBuilder()
        {
            Activities = new Collection<AddToDictionary<TKey, TValue>>();
        }

        public void AddToDictionary()
        {
            Activities.Add(new AddToDictionary<TKey,TValue>());
        }

        protected override void Execute(NativeActivityContext context)
        {
			if (this.Dictionary.Get(context) == null)
			{
				Dictionary<TKey, TValue> newDictionary = new Dictionary<TKey, TValue>();
				this.Dictionary.Set(context, newDictionary);
			}

            foreach (Activity activity in Activities)
            {
                context.ScheduleActivity(activity);
            }
        }
    }
}
